<?php
class AttrAction extends Action {
    private $brand = null;
    private $nav = null;
    public function __construct() {
        parent::__construct();
        $this->brand = new BrandModel();
        $this->nav = new NavModel();
    }
    public function index() {
        $this->tpl->assign('allAttr',$this->model->findAll());
        $this->tpl->display(SMARTY_ADMIN.'attr/show.html');
    }
    public function add() {
        if(isset($_POST['send'])) $this->model->add() ? $this->redirect->succ('?a=attr','自定义属性新增成功!') : $this->redirect->error('自定义属性新增失败!');
        $this->tpl->assign('allNav',$this->nav->findAllNav());
        $this->tpl->display(SMARTY_ADMIN.'attr/add.html');
    }
    public function update() {
        if(isset($_GET['id'])) {
            if(isset($_POST['send'])) $this->model->update() ? $this->redirect->succ(Tool::getPrevPage(),'自定义属性修改成功!') : $this->redirect->error('系统出错，修改自定义属性失败!');
            $this->tpl->assign('allNav',$this->nav->findAllNav());
            $this->tpl->assign('oneAttr',$this->model->findOne());
            $this->tpl->assign('way',array(0=>'单选',1=>'多选'));
            $this->tpl->display(SMARTY_ADMIN.'attr/update.html');
        }
    }
    public function delete() {
        if(isset($_GET['id'])) $this->model->delete() ? $this->redirect->succ(Tool::getPrevPage(),'导航删除成功!') : $this->redirect->error('系统出错，导航删除失败!');
    }
    public function checkAttrName() {
        $this->model->checkAttrName();
    }
}


?>